#!/usr/bin/python3
# -*- coding: utf-8 -*-

class Selectors:
    pass

class Block:
    pass

class Media(Block):
    pass

class Styles(Block):
    pass

class Stylesheet(list):

    def __init__(self, source=''):
        super().__init__()
        if source:
            self.(source)
        self.medias = {Media()}

    def __call__(self, source):
        self.feed(source)

    def media(self, media=Media(), stylesheet=None):
        if media and stylesheet:
            self.medias[media] = stylesheet
        elif media in self.medias:
            return self.medias[media]
        else:
            return self.medias.keys()

    def encoding(self, coding=''):
        if coding:
            self.coding = coding
            # Do something to change encoding
        else:
            return self.coding

    def styles(self, selector, styles):
        pass

    def append(self, other):
        pass

    def newatrule(self, stream, ancestors):
        pass

    def newimport(self, stream, ancestors):
        pass

    def newmedia(self, stream, ancestors):
        pass

    def newcoding(self, stream, ancestors):
        pass

    def newblock(self, stream, ancestors):
        pass

    def newprop(self, stream, ancestors):
        pass

    def newval(self, stream, ancestors):
        pass

    def newcomment(self, stream, ancestors):
        pass

    def feed(self, source):
        stream = (i for i in source)
        ancestors = [self]
        data = ''
        for char in stream:
            if char == '@':
                self.newatrule(stream, ancestors)
            elif char == '{':
                new = Selectors(data)
                ancestors.append(new)
                self.newblock(stream, ancestors)
            elif char == '/':
                char = next(stream)
                if char == '*':
                    self.newcomment(stream, ancestors)
